package com.myblog.firstjavaproject;

import java.util.Objects;

public class Person {
     private String name = null;
     private int age = 0;

     public Person(String name,int age) {
         this.name = name;
         this.age = age;
     }
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public int getAge() {
        return age;
    }

   /* @Override
    public boolean equals(Object obj) {
         if(!(obj instanceof Person))
             return false;

         Person p = (Person)obj;
         return this.getName().equals(p.getName()) && this.getAge() == p.getAge();
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age &&
                Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
